uniform sampler2D texture;

void main()
{
	float ds = dFdx(gl_TexCoord[0].s);
	float dt = dFdx(gl_TexCoord[0].t);
	float valueSample;
	
	valueSample = texture2D(texture,gl_TexCoord[0].st).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.25,0)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.5,0)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.75,0)).r;
	
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(0,dt * 0.25)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.25,dt * 0.25)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.5,dt * 0.25)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.75,dt * 0.25)).r;

	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(0,dt * 0.5)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.25,dt * 0.5)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.5,dt * 0.5)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.75,dt * 0.5)).r;

	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(0,dt * 0.75)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.25,dt * 0.75)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.5,dt * 0.75)).r;
	valueSample += texture2D(texture,gl_TexCoord[0].st + vec2(ds * 0.75,dt * 0.75)).r;
	gl_FragColor = vec4(valueSample,0,0,1.0);
}
